﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class MapManager : MonoSingleton<MapManager> {
    public const float unit = 2f;
    public const float height = 0.5f;
    public const float logic_Weight = 20;
    public const float logic_Length = 20;
    private Dictionary<Vector2, Coord> m_CoordDic = new Dictionary<Vector2, Coord>();


    public void InitMap()
    {
        for (int x = 0; x < logic_Weight; x++)
        {
            for (int y = 0; y < logic_Length; y++)
            {
                Coord tempCoord = CreatCoord(x,y);
                m_CoordDic.Add(new Vector2(x, y), tempCoord);
            }
            
        }
    }

    private Coord CreatCoord(int _x,int _y)
    {
        Coord coord = new GameObject("[" + _x.ToString() + "]" + "[" + _y.ToString() + "]", typeof(Coord)).GetComponent<Coord>();
        coord.x = _x;
        coord.y = _y;
        coord.gameObject.transform.position = new Vector3(_x * unit, height, _y * unit);
        return coord;
    }

    public Coord GetCoord(int _x, int _y)
    {
        return m_CoordDic[new Vector2((float)_x,(float)_y)];
    }
}
